package org.sdp.pearproject.controller;


import org.sdp.pearproject.controller.custom.*;
import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: TaskToTagController
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-18
 * @Version: 1.0
 * Table: pear_task_to_tag
 * Comment:
 * 任务标签映射表
 */
@RestController
@RequestMapping(value = "/task_to_tag")
public class TaskToTagController extends TaskToTagCustomController {
    static {
        addRequestClass("task_to_tag", "add", "taskToTagController", TaskToTagController.class, TaskToTagAddRequest.class);
        addRequestClass("task_to_tag", "add_encrypt", "taskToTagController", TaskToTagController.class, TaskToTagAddRequest.class);

        addRequestClass("task_to_tag", "update", "taskToTagController", TaskToTagController.class, TaskToTagUpdateRequest.class);
        addRequestClass("task_to_tag", "update_encrypt", "taskToTagController", TaskToTagController.class, TaskToTagUpdateRequest.class);

        addRequestClass("task_to_tag", "delete", "taskToTagController", TaskToTagController.class, TaskToTagDeleteRequest.class);
        addRequestClass("task_to_tag", "delete_encrypt", "taskToTagController", TaskToTagController.class, TaskToTagDeleteRequest.class);

        addRequestClass("task_to_tag", "query", "taskToTagController", TaskToTagController.class, TaskToTagQueryRequest.class);
        addRequestClass("task_to_tag", "query_encrypt", "taskToTagController", TaskToTagController.class, TaskToTagQueryRequest.class);

        addRequestClass("task_to_tag", "list", "taskToTagController", TaskToTagController.class, TaskToTagQueryRequest.class);
        addRequestClass("task_to_tag", "list_encrypt", "taskToTagController", TaskToTagController.class, TaskToTagQueryRequest.class);

        addRequestClass("task_to_tag", "count", "taskToTagController", TaskToTagController.class, TaskToTagQueryRequest.class);
        addRequestClass("task_to_tag", "count_encrypt", "taskToTagController", TaskToTagController.class, TaskToTagQueryRequest.class);

        addRequestClass("task_to_tag", "stat", "taskToTagController", TaskToTagController.class, TaskToTagQueryRequest.class);
        addRequestClass("task_to_tag", "stat_encrypt", "taskToTagController", TaskToTagController.class, TaskToTagQueryRequest.class);

    }

    @PostMapping("/add")
    public Integer addTaskToTag(@MixRequestBody TaskToTagAddRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_to_tag", "add", request, callFromEncrypt);
        return super.addTaskToTag(request);
    }

    @PostMapping("/add_encrypt")
    public String addTaskToTagEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskToTagAddRequest request = (TaskToTagAddRequest) super.decrypt("task_to_tag", "add_encrypt", strRequest, TaskToTagAddRequest.class);
        Integer result = addTaskToTag(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/update")
    public Integer updateTaskToTag(@MixRequestBody TaskToTagUpdateRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_to_tag", "update", request, callFromEncrypt);
        return super.updateTaskToTag(request);
    }

    @PostMapping("/update_encrypt")
    public String updateTaskToTagEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskToTagUpdateRequest request = (TaskToTagUpdateRequest) super.decrypt("task_to_tag", "update_encrypt", strRequest, TaskToTagUpdateRequest.class);
        Integer result = updateTaskToTag(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/delete")
    public Integer deleteTaskToTag(@MixRequestBody TaskToTagDeleteRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_to_tag", "delete", request, callFromEncrypt);
        return super.deleteTaskToTag(request);
    }

    @PostMapping("/delete_encrypt")
    public String deleteTaskToTagEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskToTagDeleteRequest request = (TaskToTagDeleteRequest) super.decrypt("task_to_tag", "delete_encrypt", strRequest, TaskToTagDeleteRequest.class);
        Integer result = deleteTaskToTag(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/query")
    public TaskToTagQueryResponse queryTaskToTag(@MixRequestBody TaskToTagQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("task_to_tag", "query", request, callFromEncrypt);
      return super.queryTaskToTag(request);
    }

    @PostMapping("/query_encrypt")
    public String queryTaskToTagEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskToTagQueryRequest request = (TaskToTagQueryRequest) super.decrypt("task_to_tag", "query_encrypt", strRequest, TaskToTagQueryRequest.class);
        TaskToTagQueryResponse result = queryTaskToTag(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/list")
    public List<TaskToTagQueryResponse> listTaskToTag(@MixRequestBody TaskToTagQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_to_tag", "list", request, callFromEncrypt);
        if (super.needTotal("task_to_tag", "list", request)) {
            super.setTotal("task_to_tag", "list", request, super.countTaskToTag(request));
        }
        return super.listTaskToTag(request);
    }

    @PostMapping("/list_encrypt")
    public String listTaskToTagEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskToTagQueryRequest request = (TaskToTagQueryRequest) super.decrypt("task_to_tag", "list_encrypt", strRequest, TaskToTagQueryRequest.class);
        List<TaskToTagQueryResponse> result = listTaskToTag(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/count")
    public Integer countTaskToTag(@MixRequestBody TaskToTagQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("task_to_tag", "count", request, callFromEncrypt);
      return super.countTaskToTag(request);
    }


    @PostMapping("/count_encrypt")
    public String countTaskToTagEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskToTagQueryRequest request = (TaskToTagQueryRequest) super.decrypt("task_to_tag", "count_encrypt", strRequest, TaskToTagQueryRequest.class);
        Integer result = countTaskToTag(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/stat")
    public BaseStatResponse statTaskToTag(@MixRequestBody TaskToTagQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_to_tag", "stat", request, callFromEncrypt);
        return super.statTaskToTag(request);
    }

    @PostMapping("/stat_encrypt")
    public String statTaskToTagEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskToTagQueryRequest request = (TaskToTagQueryRequest) super.decrypt("task_to_tag", "stat_encrypt", strRequest, TaskToTagQueryRequest.class);
        BaseStatResponse result = statTaskToTag(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    static {
        addRequestClass("task_to_tag", "tags", "taskToTagController", TaskToTagController.class, TaskToTagForTagsRequest.class);
        addRequestClass("task_to_tag", "tags_encrypt", "taskToTagController", TaskToTagController.class, TaskToTagForTagsRequest.class);
    }

    @PostMapping("/tags")
    public TaskToTagForTagsResponse tags(@MixRequestBody TaskToTagForTagsRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_to_tag", "tags", request, callFromEncrypt);
        return super.tags(request);
    }

    @PostMapping("/tags_encrypt")
    public String tagsEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskToTagForTagsRequest request = (TaskToTagForTagsRequest)decrypt("task_to_tag", "tags_encrypt", strRequest, TaskToTagForTagsRequest.class);
        TaskToTagForTagsResponse result = tags(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);
        
        return super.encrypt(request, response);
    }


}
